package com.example.gulimall.order.web;

import com.example.common.vo.order.OrderSubmitVo;
import com.example.gulimall.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

/**
 * <p>
 *
 * </p>
 *
 * @author zyred
 * @since v 0.1
 **/
@Controller
public class OrderWebController {

    @Autowired
    private OrderService orderService;

    @GetMapping("{page}.html")
    public String setPage (@PathVariable("page") String page) {
        return page;
    }

    @GetMapping("/toTrade")
    public String toTrade (Model model) {
        return this.orderService.confirmOrder (model);
    }

    @PostMapping("/submitOrder")
    public String submitOrder (OrderSubmitVo vo, Model model, RedirectAttributes attributes) {
        return this.orderService.submitOrder(vo, model, attributes);
    }

}
